//package com.northpool.operator.http.auth;
//
//import cn.hutool.core.util.StrUtil;
//import cn.hutool.http.HttpResponse;
//import cn.hutool.http.HttpUtil;
//import com.alibaba.fastjson.JSONObject;
//import com.northpool.operator.annotation.InputParam;
//import com.northpool.operator.annotation.InputParams;
//import com.northpool.operator.annotation.OperatorInfo;
//import com.northpool.operator.annotation.OutputParam;
//import com.northpool.operator.annotation.OutputParams;
//import com.northpool.operator.common.algorithm.AlgorithmBase;
//import com.northpool.operator.common.algorithm.annotation.PluginInfo;
//import com.northpool.operator.type.TypeEnum;
//
//import java.util.HashMap;
//import java.util.Map;
//
//@OperatorInfo(
//        ref = "JianmuTokenOperator",
//        name = "建木用户令牌",
//        description = ""
//)
//@OutputParams({
//        @OutputParam(ref = "token", name = "令牌")
//})
//public class JianmuTokenOperator extends AlgorithmBase {
//
//
//    @InputParams({
//            @InputParam(ref = "url", name = "服务地址", desc = "http://northpool.work:8021/stp-jianmu-api", required = true),
//            @InputParam(ref = "username", name = "用户名", required = true),
//            @InputParam(ref = "password", name = "密码", required = true, type = TypeEnum.STRING)
//    })
//    public JianmuTokenOperator() {
//    }
//
//    public static void main(String[] args) {
//        Map<String, String> params = new HashMap<>();
//        params.put("username", "admin");
//        params.put("password", "htht@123");
//        params.put("url", "http://northpool.work:8021/stp-jianmu-api");
//
//        JianmuTokenOperator op = new JianmuTokenOperator();
//        op.execute(params);
//    }
//
//    @Override
//    public void execute(Map<String, String> params) {
//        String username = params.get("username");
//        String password = params.get("password");
//        String url = StrUtil.format("{}/auth/login", params.get("url"));
//        Map<String, Object> bodyParam = new HashMap<>();
//        bodyParam.put("username", username);
//        bodyParam.put("password", password);
//
//        HttpResponse execute = HttpUtil.createPost(url).contentType("application/json").body(JSONObject.toJSONString(bodyParam)).execute();
//        int status = execute.getStatus();
//        if (status != 200) {
//            throw new RuntimeException("请求异常：" + execute.body());
//        }
//        String result = execute.body();
//        JSONObject resultObject = JSONObject.parseObject(result);
//        String token = resultObject.getString("token");
//        logResult("token", token);
//    }
//}
